
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="zh_cn">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <title>4.15.&nbsp;&#35774;&#32622;&#20803;&#32032;&#26679;&#24335; [&#28145;&#20837;&#27973;&#20986; Greasemonkey]</title>
      <link rel="shortcut icon" href="/favicon.ico">
      <link rel="stylesheet" href="../css/dig.css" type="text/css">
      <meta http-equiv="Link" content='&lt;../css/modern.css&gt;; type="text/css"; rel=stylesheet, &lt;../css/empty.css&gt;; type="text/css";
      rel=stylesheet'>
      <link rev="made" href="mailto:mark@diveintomark.org">
      <meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
      <meta name="keywords" content="Firefox, Greasemonkey, Javascript, user script, userscript">
      <link rel="start" href="../toc/index.html" title="&#28145;&#20837;&#27973;&#20986; Greasemonkey">
      <link rel="up" href="index.html" title="&#31532;&nbsp;4&nbsp;&#31456;&nbsp;&#20844;&#20849;&#27169;&#24335;">
      <link rel="prev" href="getcomputedstyle.html" title="4.14.&nbsp;&#33719;&#21462;&#20803;&#32032;&#26679;&#24335;">
      <link rel="next" href="onload.html" title="4.16.&nbsp;&#22788;&#29702;&#24050;&#28210;&#26579;&#30340;&#39029;&#38754;">
   </head>
   <body id="diveintogreasemonkey-org" class="pattern-setstyle">
      <div class="z" id="intro">
         <div class="sectionInner">
            <div class="sectionInner2">
               <div class="s">
                  <h1><a href="/" accesskey="1">&#28145;&#20837;&#27973;&#20986; Greasemonkey</a></h1>
                  <p>&#25945;&#32769;&#32593;&#32476;&#23398;&#26032;&#25226;&#25103;</p>
               </div>
               <div class="s">
                  <ul>
                     <li><a href="../">&#36215;&#22987;&#39029;</a> &middot; 
                     </li>
                     <li><a href="../toc/">&#30446;&#24405;</a> &middot; 
                     </li>
                     <li><a href="../download/">&#19979;&#36733;</a> &middot; 
                     </li>
                     <li><a href="http://greasemonkey.mozdev.org/">&#31435;&#21363;&#19979;&#36733; Greasemonkey</a></li>
                  </ul>
               </div>
            </div>
         </div>
      </div>
      <div id="main">
         <div id="mainInner">
            <p id="breadcrumb">&#24744;&#30340;&#20301;&#32622;&#65306;<a href="../">&#36215;&#22987;&#39029;</a> &#8594; <a href="../toc/index.html">&#30446;&#24405;</a> &#8594; <a href="index.html">&#20844;&#20849;&#27169;&#24335;</a> &#8594; <span class="thispage">&#35774;&#32622;&#20803;&#32032;&#26679;&#24335;</span></p>
            <div class="section" lang="zh_cn">
               <div class="titlepage">
                  <div>
                     <div>
                        <h2 class="title"><a name="pattern.setstyle" class="skip" href="#pattern.setstyle" title="link to this section"><img src="../images/permalink.gif" alt="[link]" title="link to this section" width="8" height="9"></a> 4.15.&nbsp;&#35774;&#32622;&#20803;&#32032;&#26679;&#24335;
                        </h2>
                     </div>
                     <div>
                        <div class="abstract">
                           <h3 class="title"></h3>
                           <p>&#22914;&#26524;&#21482;&#38656;&#35201;&#35774;&#32622;&#21333;&#20010;&#20803;&#32032;&#30340;&#23569;&#25968;&#26679;&#24335;&#65292;&#21487;&#20197;&#8220;<span class="quote">&#25163;&#21160;&#22320;</span>&#8221;&#22312;&#36825;&#20010;&#20803;&#32032;&#30340; <code class="property">style</code> &#23646;&#24615;&#20013;&#35774;&#32622;&#22810;&#20010;&#23376;&#23646;&#24615;&#12290;
                           </p>
                        </div>
                     </div>
                  </div>
               </div>
               <div class="example"><a name="example.pattern.setstyle" class="skip" href="#example.pattern.setstyle" title="link to this example"><img src="../images/permalink.gif" alt="[link]" title="link to this example" width="8" height="9"></a> 
                  <h3 class="title">&#20363;&nbsp;4.19.&nbsp;&#35774;&#32622;&#21333;&#20010;&#20803;&#32032;&#30340;&#26679;&#24335;</h3>
                  <p>&#20551;&#35774;&#26377;&#20010;&#20803;&#32032; ID &#20026; <code class="literal">"logo"</code>&#12290;
                  </p><pre class="programlisting ">var logo = document.getElementById('logo');
logo.style.marginTop = '2em';
logo.style.backgroundColor = 'white';
logo.style.color = 'red';</pre></div>
               <div class="warning">
                  <table class="admon" summary="">
                     <tr>
                        <td class="admonicon"><a href="../appendix/tips.html" title="&#25216;&#24039;&#28165;&#21333;"><img alt="[&#35686;&#21578;]" src="../images/warning.png" width="24" height="24" title=""></a></td>
                        <td class="admontext">
                           <p>&#24182;&#19981;&#26159;&#27599;&#20010;&#26679;&#24335;&#30340;&#23646;&#24615;&#21517;&#31216;&#37117;&#26159;&#26174;&#28982;&#30340;&#12290;&#36890;&#24120;&#65292;&#23427;&#20204;&#26377;&#30456;&#20284;&#30340;&#27169;&#24335;&#65292;&#20363;&#22914; <code class="property">margin-top</code> &#23545;&#24212; <code class="property">someElement.style.marginTop</code>&#12290;&#20294;&#26159;&#20063;&#26377;&#20363;&#22806;&#65306;<code class="property">float</code> &#23646;&#24615;&#23545;&#24212;&#21040; <code class="property">someElement.style.cssFloat</code>&#65292;&#22240;&#20026;  <code class="property">float</code> &#26159; Javascript &#30340;&#20445;&#30041;&#23383;&#12290;
                           </p>
                        </td>
                     </tr>
                  </table>
               </div>
               <div class="usedby">
                  <h3>&#23454;&#20363;</h3>
                  <ul>
                     <li>
                        <a href="http://www.firefox.net.cn/dig/download/accessbar.user.js">Access Bar</a>
                        
                     </li>
                     <li>
                        <a href="http://www.firefox.net.cn/dig/download/betterdir.user.js">BetterDir</a>
                        
                     </li>
                     <li>
                        <a href="http://www.firefox.net.cn/dig/download/blogdex-display-title.user.js">Blogdex Display Title</a>
                        
                     </li>
                     <li>
                        <a href="http://www.firefox.net.cn/dig/download/zoomtextarea.user.js">Zoom Textarea</a>
                        
                     </li>
                  </ul>
               </div>
               <div class="furtherreading"><a href="../appendix/furtherreading.html" title="&#xA;&#8220;&#21442;&#32771;&#36164;&#26009;&#8221;&#38142;&#25509;&#28165;&#21333;">
                     <h3>&#21442;&#32771;&#36164;&#26009;</h3></a><ul>
                     <li>
                        <a href="http://www.westciv.com/style_master/academy/css_tutorial/properties/">CSS &#23646;&#24615;</a>
                        
                     </li>
                  </ul>
               </div>
            </div>
            <div style="float: left">&#8592;&nbsp;<a class="NavigationArrow" href="getcomputedstyle.html">&#33719;&#21462;&#20803;&#32032;&#26679;&#24335;</a></div>
            <div style="text-align: right"><a class="NavigationArrow" href="onload.html">&#22788;&#29702;&#24050;&#28210;&#26579;&#30340;&#39029;&#38754;</a>&nbsp;&#8594;
            </div>
            <hr style="clear:both">
            <div class="footer">
               <p class="copyright">&#29256;&#26435; &copy; 2005 Mark Pilgrim &middot; <a title="&#21457;&#36865;&#32473;&#25105;&#26377;&#20110;&#27492;&#20070;&#30340;&#21453;&#39304;&#24847;&#35265;" href="mailto:mark@diveintomark.org">mark@diveintomark.org</a> &middot; <a href="../license/gpl.html" title="GNU &#36890;&#29992;&#20844;&#20849;&#35768;&#21487;&#35777;">&#20351;&#29992;&#26465;&#27454;</a></p>
            </div>
         </div>
      </div>
   </body>
</html>